#this code imports the modules that set up the elixir tables, imports the definitions (models and methods
#definitions) to find the match in order to extract the nsi
# (parse the lines from the correct column in the table)
#imports the elixir structure for the nsi table(NSIModel)

from elixir import *
import ExtractionModel as L2EM
import FileParser as l2p
import NSIElixir as nsi

#tells elixir to create the nsi table
setup_all()
create_all()

#Elixir query
l2Row = L2EM.SLA.query.filter_by(id = 1).one()
l2TextColumn = l2Row.assessment
l2Lines = l2TextColumn.splitlines()

loader = l2p.Level2Loader()
l2p15 = l2p.Level2Parser()

loader.load_lines(l2Lines)
l2p15.lines = loader.lines
l2p15.parse_lines_record15()


l2elixir = nsi.Level2DbLoader()

l2elixir.load_database(l2p15.data)

session.commit()
